infile = r'remain_pre.fa'
filter_file = r'discard_miRNA_from_miRbase2'
remain_lista = r'remain_lista'


from Bio import SeqIO
outfile = 'remain_pre2.fa'

delete_lista = []
with open(filter_file) as fila:
    for i in fila:
        k = i.split('\t')
        if len(k)>1:
            delete_lista.append(k[0])
outfile2 = open(remain_lista,'w')

with open(outfile,'w') as fila:
    for i in SeqIO.parse(infile,'fasta'):
        if i.name in delete_lista:
            print(i.name)
            pass
        else:
            fila.write('>'+str(i.name)+'\n')
            fila.write(str(i.seq)+'\n')
            outfile2.write(i.name+'\n')

outfile2.close()



